package com.hnrd.infomation_collerction.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

import com.hnrd.infomation_collerction.mapper.EntInfoCollectMapper;
import com.hnrd.infomation_collerction.pojo.EntInfoCollect;
import com.hnrd.infomation_collerction.service.EntInfoCollectService;
import com.hnrd.infomation_collerction.utils.StringToLocalDateTimeUtils;
@Service
public class EntInfoCollectServiceImpl implements EntInfoCollectService{
	@Autowired 
	private EntInfoCollectMapper entInfoCollectmapper;
	@Override
	public ResponseEntity<List<EntInfoCollect>> slectAll() {
		// TODO Auto-generated method stub
		List<EntInfoCollect> list=entInfoCollectmapper.selectAll();
		return new ResponseEntity<>(list,HttpStatus.OK);
	}
	@Override
	public ResponseEntity<Map<String, String>> insertEntInfoCollect(EntInfoCollect entInfoCollect) {
		// TODO Auto-generated method stub
		Map<String, String> map =new HashMap<>();
		map.put("msg","添加成功！");
		map.put("code","20000");
		entInfoCollect.setCreatAt(StringToLocalDateTimeUtils.getStringLocalDateTimeCTT());
		entInfoCollect.setUpdateAt(StringToLocalDateTimeUtils.getStringLocalDateTimeCTT());
		try {
			entInfoCollectmapper.insert(entInfoCollect);
			return new ResponseEntity<>(map,HttpStatus.OK);
		} catch (Exception e) {
			map.put("msg","添加失败！服务器异常！");
			map.put("code","40001");
			return new ResponseEntity<>(map,HttpStatus.BAD_REQUEST);
		}
	}

	
}
